package com.zzg.mybatis.generator.plugins;

import java.util.List;

import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;
import org.mybatis.generator.api.dom.java.TopLevelClass;

/**
 * 继承指定父类
 */
public class PageParameterPlugin extends PluginAdapter{
	
	@Override
    public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass,IntrospectedTable introspectedTable){
		makeSerializable(topLevelClass,introspectedTable);
		return true;
    }

    @Override
    public boolean modelPrimaryKeyClassGenerated(TopLevelClass topLevelClass,IntrospectedTable introspectedTable){
    	makeSerializable(topLevelClass,introspectedTable);
    	return true;
    }
    
    @Override
    public boolean modelRecordWithBLOBsClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable){
    	makeSerializable(topLevelClass,introspectedTable);
    	return true;
    }
    
    @Override
    public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,IntrospectedTable introspectedTable){
        makeSerializable(topLevelClass,introspectedTable);  
        return true;
    }
    
    /**
     * 序列化处理
     * @param topLevelClass
     * @param introspectedTable
     */
    protected void makeSerializable(TopLevelClass topLevelClass,IntrospectedTable introspectedTable){
    	//继承PageParameter
    	topLevelClass.setSuperClass("PageParameter");
        topLevelClass.addImportedType("com.gosoft.wsms.common.po.PageParameter");
    }
	
	@Override
	public boolean validate(List<String> warnings) {
		return true;
	}
}